namespace CSharpPro._1009;

public class Demo
{
    public void TestPrint1()
    {
        Console.WriteLine("1000以内的水仙花数有：");
        for (int num = 100; num < 1000; num++)
        {
            int hundreds = num / 100; 
            int tens = (num / 10) % 10; 
            int units = num % 10; 
            if (hundreds * hundreds * hundreds + tens * tens * tens + units * units * units == num)
            {
                Console.Write(num + " ");
            }
        }
        Console.WriteLine("\n");
    }

    public void TestPrint2()
    {
        Console.WriteLine("100以内的所有质数有：");
        for (int num = 2; num <= 100; num++)
        {
            bool isPrime = true;

            for (int i = 2; i <= Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                Console.Write(num + " ");
            }
        }

        Console.WriteLine();
    }
}